﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LearnNet.Entity
{
    /// <summary>
    /// 采集连接地址类
    /// </summary>
    public class Collect_PageGetLinksInfo
    {
        private string url;
        private Encoding pageEncoding;
        private string includeStr;
        private Int32 startNum;
        private Int32 endNum;
        private Int32 addNum;
        private Int32 collectNum;
        private string name;
        /// <summary>
        /// 采集名称
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        private  Dictionary<string, CollectPageInfo> pages = new Dictionary<string, CollectPageInfo>();
        /// <summary>
        /// 采集页面信息集合
        /// </summary>
        public Dictionary<string, CollectPageInfo> Pages
        {
            get { return pages; }
        }
        /// <summary>
        /// 添加采集页面信息
        /// </summary>
        /// <param name="isCollect"></param>
        /// <param name="url"></param>
        public void AddPage(bool isCollect,string url)
        {
            if (!pages.ContainsKey(url))
            {
                pages.Add(url, new CollectPageInfo(isCollect, url));
            }
        }
        /// <summary>
        /// 移除采集页面信息
        /// </summary>
        /// <param name="url"></param>
        public void RemovePage(string url)
        {
            if (pages.ContainsKey(url))
            {
                pages.Remove(url);
            }
        }
        /// <summary>
        /// 正在采集的网页
        /// </summary>
        public Int32 CollectNum
        {
            get { return collectNum; }
            set { collectNum = value; }
        }
        /// <summary>
        /// 采集连接网页地址
        /// </summary>
        public string Url
        {
            get { return url; }
            set { url = value; }
        }
        /// <summary>
        /// 远程网页地址
        /// </summary>
        public Encoding PageEncoding
        {
            get { return pageEncoding; }
            set { pageEncoding = value; }
        }

        /// <summary>
        /// 获取连接地址中包括字符
        /// </summary>
        public string IncludeStr
        {
            get { return includeStr; }
            set { includeStr = value; }
        }

        /// <summary>
        /// 连接地址中变量起始值
        /// </summary>
        public Int32 StartNum
        {
            get { return startNum; }
            set { startNum = value; }
        }

        /// <summary>
        /// 连接地址中变量结束值
        /// </summary>
        public Int32 EndNum
        {
            get { return endNum; }
            set { endNum = value; }
        }
        /// <summary>
        /// 连接地址中变量递增/递减值
        /// </summary>
        public Int32 AddNum
        {
            get { return addNum; }
            set { addNum = value; }
        }
    }
    /// <summary>
    /// 采集页面信息
    /// </summary>
    public class CollectPageInfo{

        private bool isCollect;

        private string url;

        public CollectPageInfo(bool isCollect, string url)
        {
            this.isCollect = isCollect;
            this.url = url;
        }

        /// <summary>
        /// 是否以采集
        /// </summary>
        public bool IsCollect{
            get{return isCollect;}
            set{isCollect=value;}
        }
        /// <summary>
        /// 页面地址
        /// </summary>
        public string Url{
            get{return url;}
            set{url=value;}
        }
    }
}
